import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:meal/constant/antd_icons.dart';
import 'package:meal/constant/fonts.dart';
import 'package:meal/constant/sizes.dart';
import 'package:meal/utils/colors.dart';
import 'package:meal/utils/styles.dart';
import 'package:meal/utils/tools.dart';

class Search extends StatefulWidget {
  const Search({Key? key}) : super(key: key);

  @override
  State<Search> createState() => _SearchState();
}

class _SearchState extends State<Search> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: ColorsUtils.rgba(245, 245, 245, 1),
      appBar: BrnAppBar(
        title: Container(
          padding: const EdgeInsets.only(bottom: Sizes.default5),
          child: BrnSearchText(
            outSideColor: Colors.transparent,
            innerColor: Colors.white,
            hintText: '请输入商品名称',
            hintStyle: StylesUtils.customTextStyle(color: ColorsUtils.colorCcc),
            innerPadding: const EdgeInsets.symmetric(horizontal: Sizes.default20),
            borderRadius: const BorderRadius.all(Radius.circular(Sizes.default20)),
            maxHeight: Sizes.default40,
          ),
        ),
        backgroundColor: ColorsUtils.rgba(255, 110, 83, 1),
        elevation: 0,
        actions: BrnTextAction(
          '搜索',
          iconPressed: () {},
        ),
        themeData: BrnAppBarConfig(
            appBarHeight: kToolbarHeight,
            leftAndRightPadding: Sizes.default20,
            leadIconBuilder: () => const Icon(
                  AntdIcons.left,
                  color: Colors.white,
                  size: Sizes.default20,
                  weight: 700,
                ),
            actionsStyle:
                BrnTextStyle(color: Colors.white, fontSize: Sizes.default16, fontWeight: Fonts.w4)),
      ),
      body: SingleChildScrollView(
          child: Container(
        margin: const EdgeInsets.only(top: Sizes.default10),
        padding: const EdgeInsets.symmetric(horizontal: Sizes.default20),
        decoration: const BoxDecoration(color: Colors.white),
        child: Column(
          children: [
            SizedBox(
              height: Sizes.default44,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text('历史记录', style: StylesUtils.customTextStyle(color: ColorsUtils.color797)),
                  IconButton(
                    padding: EdgeInsets.zero,
                    alignment: Alignment.centerRight,
                    icon: ImageIcon(
                      ToolsUtils.assetImageIcon('delete.png'),
                      color: ColorsUtils.parseColorFromHexString(ColorsUtils.colorCcc),
                      size: Sizes.default20,
                    ),
                    onPressed: () {},
                  )
                ],
              ),
            ),
            GridView.custom(
              padding: EdgeInsets.zero,
              physics: const NeverScrollableScrollPhysics(),
              shrinkWrap: true,
              gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                  crossAxisCount: 2, childAspectRatio: 3),
              childrenDelegate: SliverChildBuilderDelegate((context, index) {
                return Container(
                  height: Sizes.default44,
                  alignment: Alignment.centerLeft,
                  child: Text(
                    '香菇鸡块',
                    overflow: TextOverflow.ellipsis,
                    style: StylesUtils.customTextStyle(
                        color: ColorsUtils.color333, fontSize: Sizes.default15),
                  ),
                );
              }, childCount: 10),
            )
          ],
        ),
      )),
    );
  }
}
